﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;

namespace BLL.PayRecordsTransaction
{
    /// <summary>
    /// 模糊查询消费记录
    /// </summary>
    public class NomalQueryPayRecordsTransaction : QueryPayRecordsTransaction
    {
        private T_PayRecordsObject condition;

        public NomalQueryPayRecordsTransaction(T_PayRecordsObject _Condition)
        {
            this.condition = _Condition;
        }

        public IList<T_PayRecordsObject> Query()
        {
            base.Execute();
            IList<T_PayRecordsObject> resultList = new List<T_PayRecordsObject>();
            resultList = base.payRecords;
            resultList = resultList.Where(x => x.Db_PayDate >= condition.BeginDate).ToList();
            resultList = resultList.Where(x => x.Db_PayDate <= condition.EndDate).ToList();

            if (condition.Db_PayItem != string.Empty)
            {
                resultList = resultList.Where(x => x.Db_PayItem.Contains(condition.Db_PayItem)).ToList();
            }
            if (condition.Db_PayCategoryOID != 0)
            {
                resultList = resultList.Where(x => x.Db_PayCategoryOID==condition.Db_PayCategoryOID).ToList();
            }
            if (condition.Db_PayNecessity != 0)
            {
                resultList = resultList.Where(x => x.Db_PayNecessity == condition.Db_PayNecessity).ToList();
            }
            if (condition.Db_PayObject != 0)
            {
                resultList = resultList.Where(x => x.Db_PayObject == condition.Db_PayObject).ToList();
            }
            return resultList;
        }
    }
}
